#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>

int main()
{
    printf("父进程pid:%d,ppid:%d\n",getpid(),getppid());

    pid_t id = fork();
    if(id<0)return 1;
    else if(id == 0)
    {
        printf("子进程:pid %d,ppid %d,id %d\n",getpid(),getppid(),id);
    }
    else
    {
        printf("父进程:pid %d,ppid %d,id %d\n",getpid(),getppid(),id);
    }



//    printf("进程pid:%d,ppid:%d\n",getpid(),getppid());
//    sleep(1);

    //FILE* fp = fopen("file.txt","w");
    //if(fp == NULL) return 1;

    //fclose(fp);

    //while(1)
    //{
    //    printf("pid:%d,ppid:%d\n",getpid(),getppid());
    //    sleep(1);
    //}
    return 0;
}
